package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.DeleteReq;
import com.example.demo.entity.requestJson.PostOnelevelCommentReq;
import com.example.demo.entity.requestJson.PostReplyTwoCommentReq;
import com.example.demo.entity.requestJson.PostTwoLevelCommentReq;
import com.example.demo.entity.responseJson.ListResult;
import com.example.demo.entity.responseJson.PostOnelevelCommentRes;
import com.example.demo.entity.responseJson.PostTwolevelCommentRes;
import com.example.demo.service.PostCommentService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 洪俊新
 * @date : 2021/3/17 16:02
 * @description:
 */
@RestController
@RequestMapping("/author/postcomment")
@Api(value = "帖子评论接口", tags = "帖子评论接口")
public class PostCommentController {
    @Autowired
    private PostCommentService postCommentService;

    @ApiOperation(value = "用户发表一级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/putonelevelcomment")
    public BackResponseEntity<Object> putOneLevelComment(@RequestBody PostOnelevelCommentReq postOnelevelCommentReq){
        return postCommentService.putOneLevelComment(postOnelevelCommentReq);
    }

    @ApiOperation(value = "查询帖子一级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/queryonelevelcomment")
    public BackResponseEntity<ListResult<List<PostOnelevelCommentRes>>> queryOneComment(DeleteReq deleteReq){
        return postCommentService.queryPostOneComment(deleteReq);
    }

    @ApiOperation(value = "用户回复一级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/puttwolevelcomment")
    public BackResponseEntity<Object> putTwoLevelComment(@RequestBody PostTwoLevelCommentReq postTwoLevelCommentReq){
        return postCommentService.putTwoLevelComment(postTwoLevelCommentReq);
    }

    @ApiOperation(value = "查询二级评论", notes = "传parentCommentId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querytwolevelcomment")

    public BackResponseEntity<ListResult<List<PostTwolevelCommentRes>>> queryTwoeComment(DeleteReq deleteReq){
        return postCommentService.queryTwoComment(deleteReq);
    }

    @ApiOperation(value = "用户回复二级评论", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @PostMapping("/replytwolevelcomment")

    public BackResponseEntity<Object> replyTwoComment(@RequestBody PostReplyTwoCommentReq postReplyTwoCommentReq){
        return postCommentService.replyTwoComment(postReplyTwoCommentReq);
    }

    @ApiOperation(value = "查询我的评论", notes = "传userId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/querymycomment")
    public BackResponseEntity<List<PostTwolevelCommentRes>> querymyComment(DeleteReq deleteReq){
        return postCommentService.querymyComment(deleteReq);
    }

    @ApiOperation(value = "查询评论我的", notes = "传userId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @GetMapping("/queryreplymycomment")
    public BackResponseEntity<List<PostTwolevelCommentRes>> queryreplymyComment(DeleteReq deleteReq){
        return postCommentService.queryreplymyComment(deleteReq);
    }
}
